defmodule Iocp.AddressLookup do
  @moduledoc false

  @external_resource "./config/addresses.tsv"
  for line <- File.stream!(@external_resource, [:read], :line) do
    [mac_address, device_address] = line |> String.split()
    device_address = String.to_integer(device_address)
    def device_address_for(unquote(mac_address)), do: {:ok, unquote(device_address)}
    def mac_address_for(unquote(device_address)), do: {:ok, unquote(mac_address)}
  end

  def device_address_for(_), do: :error
  def mac_address_for(_), do: :error
end
